#include <vector>
using namespace std;

class Solution {
public:
    void sortColors(vector<int>& nums) {
        int left = -1,right = nums.size(),i= 0;
        while(i < right)
        {
            if(i == 0)  swap(nums[++left],nums[i]);
            else if(i == 1)     i++;
            else    swap(nums[--right],nums[i++]);
        }
    }
};